﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Web;
using WebService.Nafania.ViewLayer.Model.ObjectView;

namespace WebService.Nafania.ViewLayer.Model.Base
{
	[DataContract]
	[KnownType(typeof(ListView))]
	[KnownType(typeof(TextView))]
	[KnownType(typeof(ListTextView))]
	[KnownType(typeof(HiddenView))]
	public abstract class ObjectView
	{
		[DataMember]
		public object Value { get; set; }

		public override bool Equals(object obj)
		{
			if (obj == null) return false;

			return GetHashCode() == obj.GetHashCode();
		}

		public override int GetHashCode()
		{
			return ToString().GetHashCode();
		}

		public override string ToString()
		{
			StringBuilder sb = new StringBuilder();
			sb.AppendFormat("Class: {0}\r\n", GetType().FullName);
			sb.AppendFormat("Value: {0}\r\n", Value);
			return sb.ToString();
		}

	}
}